package jnpf.service.impl;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.base.UserInfo;
import jnpf.config.PermissionsConfig;
import jnpf.entity.*;
import jnpf.mapper.ZXGL_XiangMuFanKuiMapper;
import jnpf.model.zxgl_xiangmufankui.ZXGL_XiangMuFanKuiInfoVO;
import jnpf.model.zxgl_xiangmufankui.ZXGL_XiangMuFanKuiPagination;
import jnpf.service.*;
import jnpf.util.DateUtil;
import jnpf.util.StringUtil;
import jnpf.util.UserProvider;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * ZXGL_XiangMuFanKui
 * 版本： V2.0
 * 版权： 河北交投智能交通技术有限责任公司
 * 作者： 数字交投项目组
 * 日期： 2025-03-19
 */
@Slf4j
@Service
public class ZXGL_XiangMuFanKuiServiceImpl extends ServiceImpl<ZXGL_XiangMuFanKuiMapper, ZXGL_XiangMuFanKuiEntity> implements ZXGL_XiangMuFanKuiService {


    @Autowired
    private UserProvider userProvider;

    @Resource
    PermissionsConfig permissionsConfig;

    @Autowired
    private ZXGL_XiangMuFanKui_JiaoFuwuService zXGL_XiangMuFanKui_JiaoFuwuService;

    @Autowired
    private ZXGL_XiangMuFanKui_RenWuService zXGL_XiangMuFanKui_RenWuService;

    @Autowired
    private ZXGL_XiangMuLiXiang_MingXiService zxglXiangMuLiXiangMingXiService;

    @Autowired
    private ZXGL_RenWuFanKuiService zxglRenWuFanKuiService;

    @Autowired
    private ZXGL_XieBanXiangMuFanKuiMXService zxglXieBanXiangMuFanKuiMXService;

    @Override
    public List<ZXGL_XiangMuFanKuiEntity> getList(ZXGL_XiangMuFanKuiPagination zXGL_XiangMuFanKuiPagination) {

        List<String> AllIdList = new ArrayList();
        int total = 0;
        QueryWrapper<ZXGL_XiangMuFanKuiEntity> zXGL_XiangMuFanKuiQueryWrapper = new QueryWrapper<>();
        QueryWrapper<ZXGL_XiangMuFanKui_JiaoFuwuEntity> zXGL_XiangMuFanKui_JiaoFuwuQueryWrapper = new QueryWrapper<>();
        QueryWrapper<ZXGL_XiangMuFanKui_RenWuEntity> zXGL_XiangMuFanKui_RenWuQueryWrapper = new QueryWrapper<>();
        //TODO 增加权限逻辑
        UserInfo userInfo = userProvider.get();
        if (!userInfo.getIsAdministrator()) {
            String alldataRoleId = permissionsConfig.getAlldataRoleid();
            List<String> roleIds = userInfo.getRoleIds();
            if (roleIds == null || (StringUtils.isNotBlank(alldataRoleId) && !roleIds.contains(alldataRoleId))) {
                String userId = userInfo.getUserId();
                //项目反馈：创建人看本人数据；主责部门负责人看本部门数据；主责部门主管领导看所管理部门数据；
                zXGL_XiangMuFanKuiQueryWrapper.lambda().and(wrapper -> wrapper
                        .eq(ZXGL_XiangMuFanKuiEntity::getCreatorUserId, userId)//创建人
                        .or()
                        .eq(ZXGL_XiangMuFanKuiEntity::getDepartmentManagerZzbm, userId)//主责部门负责人看本部门数据
                        .or()
                        .eq(ZXGL_XiangMuFanKuiEntity::getDepartmentHeadleaderZzbm, userId)//主责部门主管领导看所管理部门数据
                );
            }
        }
        int zXGL_XiangMuFanKuiNum = 0;
        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getXmmc())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().like(ZXGL_XiangMuFanKuiEntity::getXmmc, zXGL_XiangMuFanKuiPagination.getXmmc());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getXmbh())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().like(ZXGL_XiangMuFanKuiEntity::getXmbh, zXGL_XiangMuFanKuiPagination.getXmbh());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getXmly())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().eq(ZXGL_XiangMuFanKuiEntity::getXmly, zXGL_XiangMuFanKuiPagination.getXmly());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getXmlx())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().eq(ZXGL_XiangMuFanKuiEntity::getXmlx, zXGL_XiangMuFanKuiPagination.getXmlx());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getXmid())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().eq(ZXGL_XiangMuFanKuiEntity::getXmid, zXGL_XiangMuFanKuiPagination.getXmid());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getJhksrq())) {
            zXGL_XiangMuFanKuiNum++;
            List<String> JhksrqList = zXGL_XiangMuFanKuiPagination.getJhksrq();
            Long fir = Long.valueOf(JhksrqList.get(0));
            Long sec = Long.valueOf(JhksrqList.get(1));

            zXGL_XiangMuFanKuiQueryWrapper.lambda().ge(ZXGL_XiangMuFanKuiEntity::getJhksrq, new Date(fir))
                    .le(ZXGL_XiangMuFanKuiEntity::getJhksrq, DateUtil.stringToDate(DateUtil.daFormatYmd(sec) + " 23:59:59"));

        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getJhjsrq())) {
            zXGL_XiangMuFanKuiNum++;
            List<String> JhjsrqList = zXGL_XiangMuFanKuiPagination.getJhjsrq();
            Long fir = Long.valueOf(JhjsrqList.get(0));
            Long sec = Long.valueOf(JhjsrqList.get(1));

            zXGL_XiangMuFanKuiQueryWrapper.lambda().ge(ZXGL_XiangMuFanKuiEntity::getJhjsrq, new Date(fir))
                    .le(ZXGL_XiangMuFanKuiEntity::getJhjsrq, DateUtil.stringToDate(DateUtil.daFormatYmd(sec) + " 23:59:59"));

        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getXzr())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().eq(ZXGL_XiangMuFanKuiEntity::getXzr, zXGL_XiangMuFanKuiPagination.getXzr());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getXzbm())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().eq(ZXGL_XiangMuFanKuiEntity::getXzbm, zXGL_XiangMuFanKuiPagination.getXzbm());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getZt())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().eq(ZXGL_XiangMuFanKuiEntity::getZt, zXGL_XiangMuFanKuiPagination.getZt());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getWcjd())) {
            zXGL_XiangMuFanKuiNum++;
            List<String> WcjdList = zXGL_XiangMuFanKuiPagination.getWcjd();
            for (int i = 0; i < WcjdList.size(); i++) {
                String id = WcjdList.get(i);
                boolean idAll = StringUtil.isNotEmpty(id);
                if (idAll) {
                    BigDecimal b = new BigDecimal(id);
                    if (i == 0) {
                        zXGL_XiangMuFanKuiQueryWrapper.lambda().ge(ZXGL_XiangMuFanKuiEntity::getWcjd, b);
                    } else {
                        zXGL_XiangMuFanKuiQueryWrapper.lambda().le(ZXGL_XiangMuFanKuiEntity::getWcjd, b);
                    }
                }
            }

        }

        if (AllIdList.size() > 0) {
            zXGL_XiangMuFanKuiQueryWrapper.lambda().in(ZXGL_XiangMuFanKuiEntity::getId, AllIdList);
        }
        //排序
        /*if (StringUtil.isEmpty(zXGL_XiangMuFanKuiPagination.getSidx())) {
            zXGL_XiangMuFanKuiQueryWrapper.lambda().orderByDesc(ZXGL_XiangMuFanKuiEntity::getJhksrq);
        } else {
            try {
                String sidx = zXGL_XiangMuFanKuiPagination.getSidx();
                ZXGL_XiangMuFanKuiEntity zXGL_XiangMuFanKuiEntity = new ZXGL_XiangMuFanKuiEntity();
                if (!StringUtil.isEmpty(sidx)){
                    Field declaredField = zXGL_XiangMuFanKuiEntity.getClass().getDeclaredField(sidx);
                    declaredField.setAccessible(true);
                    String value = declaredField.getAnnotation(TableField.class).value();
                    zXGL_XiangMuFanKuiQueryWrapper = "asc".equals(zXGL_XiangMuFanKuiPagination.getSort().toLowerCase()) ? zXGL_XiangMuFanKuiQueryWrapper.orderByAsc(value) : zXGL_XiangMuFanKuiQueryWrapper.orderByDesc(value);
                }

            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            }
        }*/
        zXGL_XiangMuFanKuiQueryWrapper.lambda().orderByDesc(ZXGL_XiangMuFanKuiEntity::getCreatorTime);
        if ((total > 0 && AllIdList.size() > 0) || total == 0) {
            Page<ZXGL_XiangMuFanKuiEntity> page = new Page<>(zXGL_XiangMuFanKuiPagination.getCurrentPage(), zXGL_XiangMuFanKuiPagination.getPageSize());
            IPage<ZXGL_XiangMuFanKuiEntity> userIPage = this.page(page, zXGL_XiangMuFanKuiQueryWrapper);
            return zXGL_XiangMuFanKuiPagination.setData(userIPage.getRecords(), userIPage.getTotal());
        } else {
            List<ZXGL_XiangMuFanKuiEntity> list = new ArrayList();
            return zXGL_XiangMuFanKuiPagination.setData(list, list.size());
        }
    }

    @Override
    public List<ZXGL_XiangMuFanKuiEntity> getTypeList(ZXGL_XiangMuFanKuiPagination zXGL_XiangMuFanKuiPagination, String dataType) {
        String userId = userProvider.get().getUserId();
        List<String> AllIdList = new ArrayList();
        int total = 0;
        QueryWrapper<ZXGL_XiangMuFanKuiEntity> zXGL_XiangMuFanKuiQueryWrapper = new QueryWrapper<>();
        QueryWrapper<ZXGL_XiangMuFanKui_JiaoFuwuEntity> zXGL_XiangMuFanKui_JiaoFuwuQueryWrapper = new QueryWrapper<>();
        QueryWrapper<ZXGL_XiangMuFanKui_RenWuEntity> zXGL_XiangMuFanKui_RenWuQueryWrapper = new QueryWrapper<>();
        int zXGL_XiangMuFanKuiNum = 0;
        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getXmmc())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().like(ZXGL_XiangMuFanKuiEntity::getXmmc, zXGL_XiangMuFanKuiPagination.getXmmc());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getXmbh())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().like(ZXGL_XiangMuFanKuiEntity::getXmbh, zXGL_XiangMuFanKuiPagination.getXmbh());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getXmly())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().eq(ZXGL_XiangMuFanKuiEntity::getXmly, zXGL_XiangMuFanKuiPagination.getXmly());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getXmlx())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().eq(ZXGL_XiangMuFanKuiEntity::getXmlx, zXGL_XiangMuFanKuiPagination.getXmlx());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getJhksrq())) {
            zXGL_XiangMuFanKuiNum++;
            List<String> JhksrqList = zXGL_XiangMuFanKuiPagination.getJhksrq();
            Long fir = Long.valueOf(JhksrqList.get(0));
            Long sec = Long.valueOf(JhksrqList.get(1));

            zXGL_XiangMuFanKuiQueryWrapper.lambda().ge(ZXGL_XiangMuFanKuiEntity::getJhksrq, new Date(fir))
                    .le(ZXGL_XiangMuFanKuiEntity::getJhksrq, DateUtil.stringToDate(DateUtil.daFormatYmd(sec) + " 23:59:59"));

        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getJhjsrq())) {
            zXGL_XiangMuFanKuiNum++;
            List<String> JhjsrqList = zXGL_XiangMuFanKuiPagination.getJhjsrq();
            Long fir = Long.valueOf(JhjsrqList.get(0));
            Long sec = Long.valueOf(JhjsrqList.get(1));

            zXGL_XiangMuFanKuiQueryWrapper.lambda().ge(ZXGL_XiangMuFanKuiEntity::getJhjsrq, new Date(fir))
                    .le(ZXGL_XiangMuFanKuiEntity::getJhjsrq, DateUtil.stringToDate(DateUtil.daFormatYmd(sec) + " 23:59:59"));

        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getXzr())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().eq(ZXGL_XiangMuFanKuiEntity::getXzr, zXGL_XiangMuFanKuiPagination.getXzr());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getXzbm())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().eq(ZXGL_XiangMuFanKuiEntity::getXzbm, zXGL_XiangMuFanKuiPagination.getXzbm());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getZt())) {
            zXGL_XiangMuFanKuiNum++;
            zXGL_XiangMuFanKuiQueryWrapper.lambda().eq(ZXGL_XiangMuFanKuiEntity::getZt, zXGL_XiangMuFanKuiPagination.getZt());
        }

        if (StringUtil.isNotEmpty(zXGL_XiangMuFanKuiPagination.getWcjd())) {
            zXGL_XiangMuFanKuiNum++;
            List<String> WcjdList = zXGL_XiangMuFanKuiPagination.getWcjd();
            for (int i = 0; i < WcjdList.size(); i++) {
                String id = WcjdList.get(i);
                boolean idAll = StringUtil.isNotEmpty(id);
                if (idAll) {
                    BigDecimal b = new BigDecimal(id);
                    if (i == 0) {
                        zXGL_XiangMuFanKuiQueryWrapper.lambda().ge(ZXGL_XiangMuFanKuiEntity::getWcjd, b);
                    } else {
                        zXGL_XiangMuFanKuiQueryWrapper.lambda().le(ZXGL_XiangMuFanKuiEntity::getWcjd, b);
                    }
                }
            }

        }

        if (AllIdList.size() > 0) {
            zXGL_XiangMuFanKuiQueryWrapper.lambda().in(ZXGL_XiangMuFanKuiEntity::getId, AllIdList);
        }
        //排序
        if (StringUtil.isEmpty(zXGL_XiangMuFanKuiPagination.getSidx())) {
            zXGL_XiangMuFanKuiQueryWrapper.lambda().orderByDesc(ZXGL_XiangMuFanKuiEntity::getJhksrq);
        } else {
            try {
                String sidx = zXGL_XiangMuFanKuiPagination.getSidx();
                ZXGL_XiangMuFanKuiEntity zXGL_XiangMuFanKuiEntity = new ZXGL_XiangMuFanKuiEntity();
                Field declaredField = zXGL_XiangMuFanKuiEntity.getClass().getDeclaredField(sidx);
                declaredField.setAccessible(true);
                String value = declaredField.getAnnotation(TableField.class).value();
                zXGL_XiangMuFanKuiQueryWrapper = "asc".equals(zXGL_XiangMuFanKuiPagination.getSort().toLowerCase()) ? zXGL_XiangMuFanKuiQueryWrapper.orderByAsc(value) : zXGL_XiangMuFanKuiQueryWrapper.orderByDesc(value);
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            }
        }
        if ("0".equals(dataType)) {
            if ((total > 0 && AllIdList.size() > 0) || total == 0) {
                Page<ZXGL_XiangMuFanKuiEntity> page = new Page<>(zXGL_XiangMuFanKuiPagination.getCurrentPage(), zXGL_XiangMuFanKuiPagination.getPageSize());
                IPage<ZXGL_XiangMuFanKuiEntity> userIPage = this.page(page, zXGL_XiangMuFanKuiQueryWrapper);
                return zXGL_XiangMuFanKuiPagination.setData(userIPage.getRecords(), userIPage.getTotal());
            } else {
                List<ZXGL_XiangMuFanKuiEntity> list = new ArrayList();
                return zXGL_XiangMuFanKuiPagination.setData(list, list.size());
            }
        } else {
            return this.list(zXGL_XiangMuFanKuiQueryWrapper);
        }
    }

    @Override
    public ZXGL_XiangMuFanKuiEntity getInfo(String id) {
        QueryWrapper<ZXGL_XiangMuFanKuiEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(ZXGL_XiangMuFanKuiEntity::getId, id);
        return this.getOne(queryWrapper);
    }

    @Override
    public void create(ZXGL_XiangMuFanKuiEntity entity) {
        this.save(entity);
    }

    @Override
    public boolean update(String id, ZXGL_XiangMuFanKuiEntity entity) {
        entity.setId(id);
        return this.updateById(entity);
    }

    @Override
    public void delete(ZXGL_XiangMuFanKuiEntity entity) {
        if (entity != null) {
            this.removeById(entity.getId());
        }
    }

    //子表方法
    @Override
    public List<ZXGL_XiangMuFanKui_JiaoFuwuEntity> GetZXGL_XiangMuFanKui_JiaoFuwuList(String id) {
        QueryWrapper<ZXGL_XiangMuFanKui_JiaoFuwuEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(ZXGL_XiangMuFanKui_JiaoFuwuEntity::getMainid, id);
        return zXGL_XiangMuFanKui_JiaoFuwuService.list(queryWrapper);
    }

    @Override
    public List<ZXGL_XiangMuFanKui_RenWuEntity> GetZXGL_XiangMuFanKui_RenWuList(String id) {
        QueryWrapper<ZXGL_XiangMuFanKui_RenWuEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(ZXGL_XiangMuFanKui_RenWuEntity::getMainid, id);
        return zXGL_XiangMuFanKui_RenWuService.list(queryWrapper);
    }

    //列表子表数据方法

    /**
     * 新增AI评分和评价
     *
     * @param zxglXiangMuFanKuiEntity
     * @return
     */
    @Override
    public boolean addAiPf(ZXGL_XiangMuFanKuiEntity zxglXiangMuFanKuiEntity) {
        QueryWrapper<ZXGL_XiangMuFanKuiEntity> queryWrapper = new QueryWrapper<>();
        LambdaQueryWrapper<ZXGL_XiangMuFanKuiEntity> eq = queryWrapper.lambda().eq(ZXGL_XiangMuFanKuiEntity::getId, zxglXiangMuFanKuiEntity.getId());
        if (baseMapper.update(zxglXiangMuFanKuiEntity, eq) > 0) {
            return true;
        } else {
            return false;
        }

    }

    /***
     * 项目反馈完成后，更新项目底表
     * @param fanKuiEntity
     * @return
     */
    @Override
    public boolean updateProjectdetail(ZXGL_XiangMuFanKuiInfoVO fanKuiEntity) {
        log.info(fanKuiEntity.getTaskId());
        log.info("------进入项目反馈——-----");
        ZXGL_XiangMuFanKuiEntity zxglXiangMuFanKuiEntity = baseMapper.selectById(fanKuiEntity.getTaskId());
        if (zxglXiangMuFanKuiEntity != null) {
            // 当前流程调用为审批最后一个节点调用，所以更改是否上传知识库状态为2，通过定时器上传附件到知识库
            zxglXiangMuFanKuiEntity.setSfsczsk(2);
            updateById(zxglXiangMuFanKuiEntity);
        }
        log.info(zxglXiangMuFanKuiEntity.getId());
        QueryWrapper<ZXGL_XiangMuFanKui_RenWuEntity> renWu = new QueryWrapper<>();
        // LambdaQueryWrapper<ZXGL_XiangMuFanKui_RenWuEntity> renWuWrapper = renWu.lambda().eq(ZXGL_XiangMuFanKui_RenWuEntity::getMainid, zxglXiangMuFanKuiEntity.getId());
        // ZXGL_XiangMuFanKui_RenWuEntity renWuDetail = zXGL_XiangMuFanKui_RenWuService.getOne(renWuWrapper);
//        QueryWrapper<ZXGL_XiangMuLiXiang_MingXiEntity> mingxi = new QueryWrapper<>();
//        LambdaQueryWrapper<ZXGL_XiangMuLiXiang_MingXiEntity> eq = mingxi.lambda().eq(ZXGL_XiangMuLiXiang_MingXiEntity::getId, fanKuiEntity.getXmlxdid());
//        ZXGL_XiangMuLiXiang_MingXiEntity mingXiDetil = zxglXiangMuLiXiangMingXiService.getOne(eq);
        ZXGL_XiangMuLiXiang_MingXiEntity mingXiDetil = new ZXGL_XiangMuLiXiang_MingXiEntity();
        /**
         *
         * 更新项目底表ZXGL_XiangMuLiXiang_MingXi，
         * 更新字段为进度、完成情况描述、交付物、上传附件、实际开始日期、实际完成日期
         */
        //项目进度
        // mingXiDetil.setXmjd(zxglXiangMuFanKuiEntity.getWcjd());
        //完成情况描述
        mingXiDetil.setWcqksm(zxglXiangMuFanKuiEntity.getWcqkms());
        //交付物
        // mingXiDetil.setJxjfw(renWuDetail.getJfw());
        //上传附件
        mingXiDetil.setXmwj(zxglXiangMuFanKuiEntity.getScwj());
        mingXiDetil.setId(zxglXiangMuFanKuiEntity.getXmid());

        // ai评分、ai评价
        mingXiDetil.setAipf(zxglXiangMuFanKuiEntity.getAipf());
        mingXiDetil.setAipj(zxglXiangMuFanKuiEntity.getAipj());
        // 领导评分、领导评价
        mingXiDetil.setRgpf(zxglXiangMuFanKuiEntity.getRgpf());
        mingXiDetil.setRgpj(zxglXiangMuFanKuiEntity.getRgpj());

        log.info("--------任务反馈结束--------------");
        return zxglXiangMuLiXiangMingXiService.updateById(mingXiDetil);
    }

    @Override
    public ZXGL_XiangMuFanKuiEntity addProjectFk(String projectId) {
        List<ZXGL_XiangMuFanKui_RenWuEntity> renWu = zxglRenWuFanKuiService.getRenWu(projectId);
        // UserInfo user = userProvider.get();
        QueryWrapper<ZXGL_XiangMuLiXiang_MingXiEntity> mingxi = new QueryWrapper<>();
        LambdaQueryWrapper<ZXGL_XiangMuLiXiang_MingXiEntity> eq = mingxi.lambda().eq(ZXGL_XiangMuLiXiang_MingXiEntity::getId, projectId);
        ZXGL_XiangMuLiXiang_MingXiEntity mingXiDetil = zxglXiangMuLiXiangMingXiService.getOne(eq);
        ZXGL_XiangMuFanKuiEntity fanKui = new ZXGL_XiangMuFanKuiEntity();
        fanKui.setXmid(mingXiDetil.getId());
        fanKui.setZxglXiangMuFanKuiRenWuEntityList(renWu);
        fanKui.setXmlxdid(mingXiDetil.getXmlxdid());
//        fanKui.setFkr(user.getUserId());
//        fanKui.setFkrbm(user.getDepartmentId());
        fanKui.setFkr(mingXiDetil.getZzr());
        fanKui.setFkrbm(mingXiDetil.getZzbm());
        fanKui.setFkrq(new DateTime());
        fanKui.setXmmc(mingXiDetil.getXmmc());
        fanKui.setXmbh(mingXiDetil.getXmbh());
        fanKui.setXmlx(mingXiDetil.getXmlx());
        fanKui.setXmly(mingXiDetil.getXmly());
        fanKui.setZrr(mingXiDetil.getZzr());
        fanKui.setZrbm(mingXiDetil.getZzbm());
        fanKui.setXzr(mingXiDetil.getXzr());
        fanKui.setXzbm(mingXiDetil.getXzbm());
        fanKui.setGzmb(mingXiDetil.getGzmb());
        fanKui.setWcjd(mingXiDetil.getXmjd());
        fanKui.setJhksrq(mingXiDetil.getJhkssj());
        fanKui.setJhjsrq(mingXiDetil.getJhjssj());
        fanKui.setZrr(mingXiDetil.getZzr());
        // 2025-04-01
//        fanKui.setXmzt(mingXiDetil.getZt());
//        fanKui.setMbz(mingXiDetil.getMbz());
        return fanKui;
    }

    @Override
    public List<ZXGL_XieBanXiangMuFanKuiMXEntity> GetZXGL_XieBanXiangMuFanKuiMXList(String id) {
        QueryWrapper<ZXGL_XieBanXiangMuFanKuiMXEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(ZXGL_XieBanXiangMuFanKuiMXEntity::getMainid, id);
        return zxglXieBanXiangMuFanKuiMXService.list(queryWrapper);
    }


    @Override
    public List<ZXGL_XieBanXiangMuFanKuiMXEntity> GetZXGL_XieBanXiangMuFanKuiMXListByXmId(String xmid) {
        QueryWrapper<ZXGL_XieBanXiangMuFanKuiMXEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(ZXGL_XieBanXiangMuFanKuiMXEntity::getXmid, xmid);
        return zxglXieBanXiangMuFanKuiMXService.list(queryWrapper);
    }

    @Override
    public boolean add(ZXGL_XiangMuFanKuiEntity entity) {
        return baseMapper.add(entity) > 0;
    }
}